home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
sr.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-09-26
|
13KB
|
392 lines
#include <exec/types.h>
#include <libraries/dos.h>
#include <intuition/intuition.h>
#include "register.h"
#define INFO_ZEILEN 16
UBYTE *Info[]={"ATUtilities Shareware-Registrierkarte\n\n",
"Anhand der folgenden Angaben können Sie mit Hilfe des Programms\n",
"\"Registrierung\" Ihre ATUtilities registrieren. Starten Sie es\n",
"jetzt und geben Sie die unten stehenden Angaben an.\n\n",
"Wichtig: Der angegebene Code berechnet sich aus den Adressangaben.\n",
" Ihre Eingabe muß mit den Angaben unten Unbedingt überein-\n",
" stimmen.\n\n",
"Klicken Sie nach der Eingabe auf \"Registrieren\", so öffnet sich,\n",
"ein neues Fenster mit Informationen über die Registrierten Programme.\n",
"Sobald Sie das Close-Gadget klicken, wird im Verzeichnis\n",
"AT: die Datei ATUtilities.reg erstellt. Durch sie\n",
"erkennen die einzelnen Programme automatisch die Registrierung.\n",
"Solle nach Klicken auf \"Registrieren\" eine Fehlermeldung erscheinen,\n",
"so prüfen Sie, ob die gemachten Eingaben mit den Angaben auf diesem\n",
"Blatt übereinstimmen. Nach der Korrektur der Daten klicken Sie erneut\n",
"auf \"Registrieren\"\n\n\n\n\n"};
UBYTE *NumFile="REG:Registration.#";
struct Library *ATUtilitiesBase;
struct Library *GfxBase;
struct Library *IntuitionBase;
VOID Kill();
VOID Out();
VOID SaveRegNo();
LONG LoadRegNo();
VOID main()
{
LONG regno;
UBYTE P[100];
UBYTE *vn,*nn,*st,*la,*pl,*or;
BOOL ende,bool;
UBYTE s1[50],s2[50];
UWORD z;
REGISTER UWORD i,j;
REGISTER ULONG Class;
register struct FileHandle *fh;
register struct TextFont *opal;
register struct Window *win;
register struct RastPort *rp;
register struct IntuiMessage *msg;
register struct Gadget *gad;
bool=FALSE;
GfxBase=OpenLibrary("graphics.library",0L);
if(GfxBase==NULL) exit(0);
IntuitionBase=OpenLibrary("intuition.library",0L);
if(IntuitionBase==NULL) exit(0);
ATUtilitiesBase=OpenLibrary("at-utilities.library",0);
if(ATUtilitiesBase!=NULL)
{
win=CreateStdWindow("ATUtilities - Shareware-Registrierung",
25,25,590,172,CLOSEWINDOW|GADGETUP,
WINDOWCLOSE|WINDOWDRAG|WINDOWDEPTH|ACTIVATE);
if(win!=NULL)
{
rp=win->RPort;
opal=GetOpalFont();
if(opal) SetFont(rp,opal);
SelectStdFPen(rp);
CreateBoolGadget(win,15,155,160,12,"Registrieren",1);
CreateBoolGadget(win,180,155,160,12,"Abbruch",2);
CreateBoolGadget(win,410,155,160,12,"Information",3);
vn=CreateStringGadget(win,150,89,420,12,NULL,50,0);
nn=CreateStringGadget(win,150,101,420,12,NULL,50,0);
st=CreateStringGadget(win,150,113,420,12,NULL,50,0);
la=CreateStringGadget(win,150,125,40,12,NULL,4,0);
pl=CreateIntegerGadget(win,195,125,80,12,NULL,6,0);
or=CreateStringGadget(win,280,125,290,12,NULL,50,0);
WriteText(rp,40,22,"Shareware-Registrierung für folgende Programme:");
j=15; z=30;
for(i=0;i<SYS_COUNT;i++)
{
CreateBoolGadget(win,j,z,25,12,"!",1000+i);
DrawNTextBorder(win,j+28,z,240,12,Programs[i].Name);
if(j==15) j=300; else { j=15; z+=15; }
P[i]=0;
}
WriteText(rp,20,98,"Vorname:");
WriteText(rp,20,110,"Nachname:");
WriteText(rp,20,122,"Str./Nummer:");
WriteText(rp,20,134,"Land/Plz./Ort:");
WriteText(rp,20,150,"Reg. Code:");
ende=FALSE;
while(ende==FALSE)
{
WaitPort(win->UserPort);
msg=GetMsg(win->UserPort);
Class=msg->Class;
gad=msg->IAddress;
ReplyMsg(msg);
switch(Class)
{
case CLOSEWINDOW:
ende=TRUE;
break;
case GADGETUP:
switch(gad->GadgetID)
{
case 1:
Kill(vn,50);
Kill(nn,50);
Kill(st,50);
Kill(la,4);
Kill(pl,6);
Kill(or,50);
strcpy(&Kunde.Vorname,vn);
strcpy(&Kunde.Nachname,nn);
strcpy(&Kunde.Straße,st);
strcpy(&Kunde.Land,la);
strcpy(&Kunde.Postleitzahl,pl);
strcpy(&Kunde.Ort,or);
RefreshGadgets(win->FirstGadget,win,NULL);
z=GetStringCode(vn,CODE_VN);
sprintf(&s2,"%04lx",z);
strcpy(&s1,&s2);
z=GetStringCode(nn,CODE_NN);
sprintf(&s2,"%04lx",z);
strcat(&s1,&s2);
z=GetStringCode(st,CODE_ST);
sprintf(&s2,"%04lx",z);
strcat(&s1,&s2);
z=GetStringCode(la,CODE_LA);
sprintf(&s2,"%04lx",z);
strcat(&s1,&s2);
z=GetStringCode(pl,CODE_PL);
sprintf(&s2,"%04lx",z);
strcat(&s1,&s2);
z=GetStringCode(or,CODE_OR);
sprintf(&s2,"%04lx",z);
strcat(&s1,&s2);
z=0;
for(i=0;i<SYS_COUNT;i++)
{
if(P[i]==1)
{
z+=Programs[i].Code;
}
}
sprintf(&s2,"%02lx",z);
strcat(&s1,&s2);
z=GetCodeCode(&s1);
sprintf(&s2,"%04lx",z);
strcat(&s1,&s2);
DrawCNTextBorder(win,150,141,420,12,&s1);
strcpy(&Kunde.Code,&s1);
i=0;
z=GetStringCode(vn,CODE_VN);
i+=TestCode(&s1,z,VN1,VN2,VN3,VN4);
z=GetStringCode(nn,CODE_NN);
i+=TestCode(&s1,z,NN1,NN2,NN3,NN4);
z=GetStringCode(st,CODE_ST);
i+=TestCode(&s1,z,ST1,ST2,ST3,ST4);
z=GetStringCode(la,CODE_LA);
i+=TestCode(&s1,z,LA1,LA2,LA3,LA4);
z=GetStringCode(pl,CODE_PL);
i+=TestCode(&s1,z,PL1,PL2,PL3,PL4);
z=GetStringCode(or,CODE_OR);
i+=TestCode(&s1,z,OR1,OR2,OR3,OR4);
z=GetCodeCode(&s1);
i+=TestCodeCode(&s1,z,CO1,CO2,CO3,CO4);
if(i!=0)
{
InfoRequest("Verschlüsselungsfehler!");
}
else
{
ende=bool=MultiRequest("Überprüfung erfolgreich beendet.",
"Wollen Sie die Daten übernehmen?",
"Ja, Übernehmen","Nein, Zurück");
}
break;
case 2:
ende=TRUE;
break;
case 3:
InformationBox("ATUtilities Registrator - Information",
"$VER: Registrator - Version 4.0",
"Copyright (C) 1993 by",
"Thomas Dreibholz",
"All rights reserved.",
"AT:Icons/Register");
break;
default:
i=gad->GadgetID;
if(i>=1000)
{
i-=1000;
if(P[i]==0) P[i]=1; else P[i]=0;
j=15; z=30;
for(i=0;i<SYS_COUNT;i++)
{
if(P[i]==1)
{ DrawPBorder(win,j+28,z,240,12); }
else
{ DrawNBorder(win,j+28,z,240,12); }
if(j==15) j=300; else { j=15; z+=15; }
}
}
break;
}
break;
}
}
DeleteStdWindow(win);
if(bool==TRUE)
{
regno=LoadRegNo();
if(regno==-1) regno=0;
if(regno!=-1)
{
win=CreateStdWindow("ATUtilities - Shareware-Registrierung",
25,25,590,192,CLOSEWINDOW|GADGETUP,
WINDOWCLOSE|WINDOWDRAG|WINDOWDEPTH|ACTIVATE);
if(win!=NULL)
{
rp=win->RPort;
if(opal) SetFont(rp,opal);
SelectStdFPen(rp);
CreateBoolGadget(win,15,175,150,12,"Drucken",1);
CreateBoolGadget(win,170,175,150,12,"Okay",2);
CreateBoolGadget(win,335,175,150,12,"Abbruch",3);
sprintf(&s2,"Eingetragener Benutzer der Reg. #%06ld:",regno);
WriteText(rp,15,25,&s2);
WriteText(rp,15,40,&Kunde.Vorname);
WriteText(rp,15,50,&Kunde.Nachname);
WriteText(rp,15,60,&Kunde.Straße);
WriteText(rp,15,70,&Kunde.Land);
WriteText(rp,80,70,"-");
WriteText(rp,100,70,&Kunde.Postleitzahl);
WriteText(rp,200,70,&Kunde.Ort);
WriteText(rp,15,85,"Folgende Programme wurden registriert:");
i=GETPRG(Kunde.Code);
j=95;
for(z=0;z<SYS_COUNT;z++)
{
if((i & (Programs[z].Code)) || (Programs[z].Code==0))
{
WriteText(rp,15,j,Programs[z].Name);
j+=10;
}
}
ende=FALSE;
while(ende==FALSE)
{
WaitPort(win->UserPort);
msg=GetMsg(win->UserPort);
Class=msg->Class;
gad=msg->IAddress;
ReplyMsg(msg);
switch(Class)
{
case CLOSEWINDOW:
ende=TRUE;
break;
case GADGETUP:
switch(gad->GadgetID)
{
case 1:
fh=Open("PRT:",MODE_NEWFILE);
if(fh!=NULL)
{
for(i=0;i<INFO_ZEILEN;i++) Out(fh,Info[i]);
Out(fh,"Vorname: "); Out(fh,&Kunde.Vorname); Out(fh,"\n");
Out(fh,"Nachname: "); Out(fh,&Kunde.Nachname); Out(fh,"\n");
Out(fh,"Straße: "); Out(fh,&Kunde.Straße); Out(fh,"\n");
Out(fh,"Land: "); Out(fh,&Kunde.Land); Out(fh,"\n");
Out(fh,"Postleitzahl: "); Out(fh,&Kunde.Postleitzahl); Out(fh,"\n");
Out(fh,"Ort: "); Out(fh,&Kunde.Ort); Out(fh,"\n\n");
Out(fh,"Reg. Code: "); Out(fh,&s1); Out(fh,"\n\n\n\n");
sprintf(&s2,"%06ld",regno);
Out(fh,"Reg. #"); Out(fh,&s2); Out(fh,"\n");
Close(fh);
}
else
{
InfoRequest("Drucken nicht möglich!");
}
break;
case 2:
ende=TRUE;
sprintf(&s2,"REG:#%06ld",regno);
fh=Open(&s2,MODE_NEWFILE);
if(fh!=NULL)
{
Out(fh,"Vorname: "); Out(fh,&Kunde.Vorname); Out(fh,"\n");
Out(fh,"Nachname: "); Out(fh,&Kunde.Nachname); Out(fh,"\n");
Out(fh,"Straße: "); Out(fh,&Kunde.Straße); Out(fh,"\n");
Out(fh,"Land: "); Out(fh,&Kunde.Land); Out(fh,"\n");
Out(fh,"Postleitzahl: "); Out(fh,&Kunde.Postleitzahl); Out(fh,"\n");
Out(fh,"Ort: "); Out(fh,&Kunde.Ort); Out(fh,"\n\n");
Out(fh,"Reg. Code: "); Out(fh,&s1); Out(fh,"\n\n\n\n");
sprintf(&s2,"%06ld",regno);
Out(fh,"Reg. #"); Out(fh,&s2); Out(fh,"\n");
Close(fh);
regno++;
SaveRegNo(regno);
}
else
{
InfoRequest("Daten konnten nicht gespeichert werden!");
}
break;
case 3:
ende=TRUE;
break;
}
break;
}
}
DeleteStdWindow(win);
}
else
{
InfoRequest("Kein Speicher für Fenster!");
}
}
}
if(opal) CloseFont(opal);
}
else
{
InfoRequest("Kein Speicher für Fenster!");
}
CloseLibrary(ATUtilitiesBase);
}
else
{
printf("Keine ATUtilities-Library!\n");
}
CloseLibrary(IntuitionBase);
CloseLibrary(GfxBase);
exit(0);
}
VOID Kill(str,len)
UBYTE *str;
UWORD len;
{
WORD i;
for(i=len;i>strlen(str);i--)
{
str[i]=0x00;
}
for(i=(strlen(str))-1;i>0;i--)
{
if(str[i]==' ') str[i]=0x00; else break;
}
}
VOID Out(fh,str)
struct FileHandle *fh;
UBYTE *str;
{
Write(fh,str,strlen(str));
}
LONG LoadRegNo()
{
LONG l;
register struct FileHandle *fh;
fh=Open(NumFile,MODE_OLDFILE);
if(fh==NULL) return(-1);
Read(fh,&l,4L);
Close(fh);
return(l);
}
VOID SaveRegNo(l)
{
register struct FileHandle *fh;
fh=Open(NumFile,MODE_NEWFILE);
if(fh==NULL) return;
Write(fh,&l,4L);
Close(fh);
}